package org.atmars.interceptor;

import java.util.Map;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

public class ZhangInterceptor extends MethodFilterInterceptor {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public String intercept(ActionInvocation arg0) throws Exception {
		// TODO Auto-generated method stub
		
		Map session=ActionContext.getContext().getSession();
		return null;
	}

	@Override
	 protected String doIntercept(ActionInvocation action) throws Exception {  
		       Map<String, Object> session = ActionContext.getContext().getSession();  
		       String user = (String)session.get("user");  
		       if(user != null && !"".equals(user)){  
		            return action.invoke();  
		       }else{  
		           session.put("error", "your user or pwd is error, please login again...");  
		           return Action.LOGIN;  
		       }  
		  
		    }  

}
